#include "gammanode.h"

GammaNode::GammaNode(double val):
        Node(val)
{
    alphaNode = -1;
    betaNode  = -1;    
}

GammaNode::GammaNode(QString lbl, double val, double sd, Node * alphaNode, Node * betaNode, bool observed):
        Node(lbl, val, sd, observed)
{    
    setAlphaNode(alphaNode);
    setBetaNode(betaNode);
}

bool GammaNode::inRange(double v)
{
    return 0.0 < v;
}

void GammaNode::setAlphaNode(Node * node)
{
    alphaNode = addParentNode(node);
}

void GammaNode::setBetaNode(Node * node)
{
    betaNode = addParentNode(node);
}

double GammaNode::computeLogLikelihood()
{    
    double a = parents->at(alphaNode)->getValue();

    double b = parents->at(betaNode)->getValue();

    double val = gsl_ran_gamma_pdf(this->getValue(), a, b);

    return VALID_LOG(val);
}
